﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Diagnostics;

namespace StarfleetCommanderDomain.Game
{
    [DebuggerDisplay("\\{ LocationName = {LocationName}, Location = {Location}, Ore = {Ore}, Crystal = {Crystal}, Hydrogen = {Hydrogen}, PlayerName = {PlayerName}, CombatUnits = {CombatUnits}, Buildings = {Buildings}, Techs = {Techs} \\}")]
    public class EspionageModel : IEquatable<EspionageModel>
    {
        private readonly string _LocationName;
        private readonly Location _Location;
        private readonly int _Ore;
        private readonly int _Crystal;
        private readonly int _Hydrogen;
        private readonly string _PlayerName;
        private readonly bool? _hasDefenses;
		private readonly CombatUnitContainer _CombatUnits;
        private readonly BuildingContainer _Buildings;
        private readonly TechContainer _Techs;

        public EspionageModel(string locationName, Location location, int ore, int crystal, int hydrogen, bool? hasDefenses, string playerName,
            CombatUnitContainer combatUnits = null, BuildingContainer buildings = null, TechContainer techs = null)
        {
            Debug.Assert(playerName.IsNullOrEmpty() == false);
            _LocationName = locationName;
            _Location = location;
            _Ore = ore;
            _Crystal = crystal;
            _Hydrogen = hydrogen;
            _hasDefenses = hasDefenses;
            _PlayerName = playerName;
            _CombatUnits = combatUnits;
            _Buildings = buildings;
            _Techs = techs;
        }   

        public override bool Equals(object obj)
        {
            if (obj is EspionageModel)
                return Equals((EspionageModel)obj);
            return false;
        }
        public bool Equals(EspionageModel obj)
        {
            if (obj == null)
                return false;
            if (!EqualityComparer<string>.Default.Equals(_LocationName, obj._LocationName))
                return false;
            if (!EqualityComparer<Location>.Default.Equals(_Location, obj._Location))
                return false;
            if (!EqualityComparer<int>.Default.Equals(_Ore, obj._Ore))
                return false;
            if (!EqualityComparer<int>.Default.Equals(_Crystal, obj._Crystal))
                return false;
            if (!EqualityComparer<int>.Default.Equals(_Hydrogen, obj._Hydrogen))
                return false;
            if (!EqualityComparer<string>.Default.Equals(_PlayerName, obj._PlayerName))
                return false;
			if (!EqualityComparer<CombatUnitContainer>.Default.Equals(_CombatUnits, obj._CombatUnits))
                return false;
            if (!EqualityComparer<BuildingContainer>.Default.Equals(_Buildings, obj._Buildings))
                return false;
            if (!EqualityComparer<TechContainer>.Default.Equals(_Techs, obj._Techs))
                return false;
            return true;
        }
        public override int GetHashCode()
        {
            int hash = 0;
            hash ^= EqualityComparer<string>.Default.GetHashCode(_LocationName);
            hash ^= EqualityComparer<Location>.Default.GetHashCode(_Location);
            hash ^= EqualityComparer<int>.Default.GetHashCode(_Ore);
            hash ^= EqualityComparer<int>.Default.GetHashCode(_Crystal);
            hash ^= EqualityComparer<int>.Default.GetHashCode(_Hydrogen);
            hash ^= EqualityComparer<string>.Default.GetHashCode(_PlayerName);
            hash ^= EqualityComparer<CombatUnitContainer>.Default.GetHashCode(_CombatUnits);
            hash ^= EqualityComparer<BuildingContainer>.Default.GetHashCode(_Buildings);
            hash ^= EqualityComparer<TechContainer>.Default.GetHashCode(_Techs);
            return hash;
        }
        public override string ToString()
        {
            return String.Format("{{ LocationName = {0}, Location = {1}, Ore = {2}, Crystal = {3}, Hydrogen = {4}, PlayerName = {5}, CombatUnits = {6}, Buildings = {7}, Techs = {8} }}", _LocationName, _Location, _Ore, _Crystal, _Hydrogen, _PlayerName, _CombatUnits, _Buildings, _Techs);
        }

        public string LocationName
        {
            get
            {
                return _LocationName;
            }
        }
        public Location Location
        {
            get
            {
                return _Location;
            }
        }
        public int Ore
        {
            get
            {
                return _Ore;
            }
        }
        public int Crystal
        {
            get
            {
                return _Crystal;
            }
        }
        public int Hydrogen
        {
            get
            {
                return _Hydrogen;
            }
        }

        public bool? HasDefenses
        {
            get { return _hasDefenses; }
        }

        public string PlayerName
        {
            get
            {
                return _PlayerName;
            }
        }
		public CombatUnitContainer CombatUnits
        {
            get
            {
                return _CombatUnits;
            }
        }
        public BuildingContainer Buildings
        {
            get
            {
                return _Buildings;
            }
        }
        public TechContainer Techs
        {
            get
            {
                return _Techs;
            }
        }
    }
}